<?php

namespace api\models;

use Yii;

/**
 * This is the model class for table "async_download_task".
 *
 * @property integer $id
 * @property string $task_id
 * @property string $task_log
 * @property integer $uid
 * @property string $file_name
 * @property string $file_ext
 * @property string $search_params
 * @property string $show_search_text
 * @property integer $status
 * @property string $file_path
 * @property string $end_time
 * @property string $error_log
 * @property integer $try_times
 * @property string $create_at
 * @property string $update_at
 * @property string $disable_at
 */
class AsyncDownloadTask extends \yii\db\ActiveRecord
{
    //生成错误
    const STATUS_ERROR = 0;
    //未完成
    const STATUS_NOT_YET_END = 1;
    //进行中
    const STATUS_RUNTIME = 2;
    //已结束
    const STATUS_ALREADY_END = 3;
    //已失效
    const STATUS_DISABLE = 4;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'async_download_task';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('test_3');
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['task_log', 'search_params', 'show_search_text', 'error_log'], 'string'],
            [['uid', 'file_name', 'search_params', 'show_search_text'], 'required'],
            [['uid', 'status', 'try_times'], 'integer'],
            [['end_time', 'create_at', 'update_at', 'disable_at'], 'safe'],
            [['task_id'], 'string', 'max' => 50],
            [['file_name'], 'string', 'max' => 150],
            [['file_ext'], 'string', 'max' => 10],
            [['file_path'], 'string', 'max' => 300],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'task_id' => 'Task ID',
            'task_log' => 'Task Log',
            'uid' => 'Uid',
            'file_name' => 'File Name',
            'file_ext' => 'File Ext',
            'search_params' => 'Search Params',
            'show_search_text' => 'Show Search Text',
            'status' => 'Status',
            'file_path' => 'File Path',
            'end_time' => 'End Time',
            'error_log' => 'Error Log',
            'try_times' => 'Try Times',
            'create_at' => 'Create At',
            'update_at' => 'Update At',
            'disable_at' => 'Disable At',
        ];
    }
}
